import Request from "./request";
import { BASE_URL, TIME_OUT } from "./request/config";
import { useUserStoreHook } from "@/store/modules/user";
const request = new Request({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  headers: {
    "Content-Type": "application/json;charset=UTF-8",
    "X-Requested-With": "XMLHttpRequest",
  },
  interceptors: {
    // 请求拦截器
    requestInterceptors: (config) => {
			console.log("实例请求拦截器");
			const userStore = useUserStoreHook();
			config.headers['Authorization'] = userStore.token
      return config;
    },
  },
});
export const requestFile = new Request({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  headers: {
    "Content-Type": "multipart/form-data",
    "X-Requested-With": "XMLHttpRequest",
  },
  isShowing: false,
});
export const requestForm = new Request({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  headers: {
    "Content-Type": "multipart/form-data",
    "X-Requested-With": "XMLHttpRequest",
  },
  isShowing: false,
});
export default request;
